using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using bitzhuwei.Compiler;

namespace bitzhuwei.AnsiCFormat {
    /// <summary>
    /// Correspond to the Vn node type_specifier in the grammar(AnsiC).
    /// </summary>
    internal abstract partial class Vntype_specifier : IFullFormatter {
        // [091]=type_specifier : 'void' ;
        // [092]=type_specifier : 'char' ;
        // [093]=type_specifier : 'short' ;
        // [094]=type_specifier : 'int' ;
        // [095]=type_specifier : 'long' ;
        // [096]=type_specifier : 'float' ;
        // [097]=type_specifier : 'double' ;
        // [098]=type_specifier : 'signed' ;
        // [099]=type_specifier : 'unsigned' ;
        // [100]=type_specifier : struct_or_union_specifier ;
        // [101]=type_specifier : enum_specifier ;
        // [102]=type_specifier : 'type_name' ;

        public abstract TokenRange Scope { get; }

        public abstract void Format(TextWriter writer, FormatContext context);

        public abstract void FullFormat(BlankConfig preConfig, TextWriter writer, FormatContext context);

        public abstract IEnumerable<string> YieldTokens(TextWriter writer, FormatContext context);
        public class token_ : Vntype_specifier {
            private readonly Token r0;

            /// <summary>
            /// [091]=type_specifier : 'void' ;
            /// [092]=type_specifier : 'char' ;
            /// [093]=type_specifier : 'short' ;
            /// [094]=type_specifier : 'int' ;
            /// [095]=type_specifier : 'long' ;
            /// [096]=type_specifier : 'float' ;
            /// [097]=type_specifier : 'double' ;
            /// [098]=type_specifier : 'signed' ;
            /// [099]=type_specifier : 'unsigned' ;
            /// [100]=type_specifier : struct_or_union_specifier ;
            /// [101]=type_specifier : enum_specifier ;
            /// [102]=type_specifier : 'type_name' ;
            /// </summary>
            /// <param name="r0"></param>
            public token_(
                   Token r0/* reserved word is omissible */
                   ) {
                this.r0 = r0;
                this._scope = new TokenRange(r0);
            }

            private readonly TokenRange _scope;
            public override TokenRange Scope => _scope;

            public override void FullFormat(BlankConfig preConfig, TextWriter writer, FormatContext context) {
                context.PrintBlanksAnd(this.r0, preConfig, writer);
            }

            public override IEnumerable<string> YieldTokens(TextWriter writer, FormatContext context) {
                throw new NotImplementedException();
            }
            public override void Format(TextWriter writer, FormatContext context) {
                throw new NotImplementedException();
            }
        }
        public class struct_union_ : Vntype_specifier {
            private readonly Vnstruct_or_union_specifier r0;

            /// <summary>
            /// [100]=type_specifier : struct_or_union_specifier ;
            /// </summary>
            /// <param name="r0"></param>
            public struct_union_(Vnstruct_or_union_specifier r0) {
                this.r0 = r0;
                this._scope = new TokenRange(r0);
            }

            private readonly TokenRange _scope;
            public override TokenRange Scope => _scope;

            public override void FullFormat(BlankConfig preConfig, TextWriter writer, FormatContext context) {
                context.PrintBlanksAnd(this.r0, preConfig, writer);
            }

            public override IEnumerable<string> YieldTokens(TextWriter writer, FormatContext context) {
                throw new NotImplementedException();
            }
            public override void Format(TextWriter writer, FormatContext context) {
                throw new NotImplementedException();
            }
        }
        public class enum_ : Vntype_specifier {
            private readonly Vnenum_specifier r0;

            /// <summary>
            /// [101]=type_specifier : enum_specifier ;
            /// </summary>
            /// <param name="r0"></param>
            public enum_(Vnenum_specifier r0) {
                this.r0 = r0;
                this._scope = new TokenRange(r0);
            }

            private readonly TokenRange _scope;
            public override TokenRange Scope => _scope;

            public override void FullFormat(BlankConfig preConfig, TextWriter writer, FormatContext context) {
                context.PrintBlanksAnd(this.r0, preConfig, writer);
            }

            public override IEnumerable<string> YieldTokens(TextWriter writer, FormatContext context) {
                throw new NotImplementedException();
            }
            public override void Format(TextWriter writer, FormatContext context) {
                throw new NotImplementedException();
            }
        }

    }
}
